package com.koron.order.cockpitStats.business.bean.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.text.NumberFormat;

/**
 * @ClassName DefectStatsVo
 * @description 驾驶舱面板 缺陷统计
 * @Author zhouj
 * @Date 2022/5/24 11:57
 */
@Data
public class DefectStatsVo {

    @ApiModelProperty("组织id")
    private String orgId;

    @ApiModelProperty("组织名称")
    private String orgName;

    @ApiModelProperty("消缺及时率")
    private String delDefectOnTimeRate;

    @ApiModelProperty("抢修")
    private int rescue;

    @ApiModelProperty("一类")
    private int oneclass;

    @ApiModelProperty("二类")
    private int twoclass;

    @ApiModelProperty("三类")
    private int threeclass;

    @ApiModelProperty("紧急（线路）")
    private int urgent_line;

    @ApiModelProperty("重大（线路）")
    private int major_line;

    @ApiModelProperty("一般（线路）")
    private int commonly_line;

    @ApiModelProperty("及时归档缺陷")
    private int isFinishOnTime;

    @ApiModelProperty("已归档缺陷")
    private int isFinish;

    @ApiModelProperty("未归档缺陷")
    private int notFinish;

    @ApiModelProperty("缺陷总数")
    private int total;

    public String getDelDefectOnTimeRate() {
        //仅在json返回处理

        if (total == 0 || isFinishOnTime == 0) {
            return "100";
        }

        //isFinishOnTime/total
        // 创建一个数值格式化对象
        NumberFormat numberFormat = NumberFormat.getInstance();
        // 设置精确到小数点后2位
        numberFormat.setMaximumFractionDigits(2);

        return numberFormat.format((float) isFinishOnTime / (float) total * 100);
    }

    public int getNotFinish() {
        return total - isFinish;
    }

}
